/**
 * 
 * 菜单管理js
 */

/**
 * 预加载项
 * */
$(function() {
	//初始化页面需要的URL
	URL_MAP = $(".url-section");
	SELECT_URL = URL_MAP.find("input[name='select']").val();
	INSERT_URL = URL_MAP.find("input[name='insert']").val();
	DELETE_URL = URL_MAP.find("input[name='delete']").val();
//	alert(SELECT_URL+"+"+INSERT_URL+"+"+DELETE_URL);
	
	//数据表格预加载
	loadGrid(SELECT_URL);
	// 搜索按钮点击事件
	$("#menuSearchBtn").on("click",function() {
				$("#MenuGrid").bootstrapTable("load",
						$("#MenuSearchForm").serializeJSON());
				});
	$('#menuName').textbox({
		type: "text",
		prompt: "请输入菜单名称"
	});
});
function loadGrid(url) {
	var config = {
			url : url,
			//postData : postData,
			colNames : ['菜单名称', '上级菜单', '菜单等级', '排序', '菜单路径'],
			colModel : [
			            {name: 'systemName', index: 'systemName', width: '100'},
			            {name: 'systemParentId', index: 'systemParentId', width: '100'},
			            {name: 'menuLev', index: 'menuLev', width: '100'},
			            {name: 'menuSort', index: 'menuSort', width: '100'},
			            {name: 'menuUrl', index: 'menuUrl', width: '100'}
			            ],
            pager : '#Menupager',
            multiselect : false, //不允许出现多选框
			jsonReader : {
				page : "page",
				total : "total",
				records : "records",
				root : "rows",
				repeatitems : false
			}
	};
	$("#MenuGrid").jqGrid($.extend(JQGRID_BASE_CONFIG, config));
	// Add responsive to jqGrid
	$(window).bind('resize', function () {
	    var width = $('.jqGrid_wrapper').width();
	    $('#MenuGrid').setGridWidth(width);
	});
};